/** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
**/

var files = [		
	"./js/lib/jquery-1.4.2.min.js",
	"./js/lib/platformservices.js",
	"./localizedTextStrings.js",
	"./settings.js",
	"./js/webtv/alert.js",
	"./js/webtv/scroller.js",
	"./js/webtv/miniview.js",
	"./js/webtv/terms.js",
	"./js/webtv/search.js",
	"./js/webtv/rightmenu.js",
	"./js/webtv/rss.js",
	"./js/webtv/player.js",
	"./js/webtv/imagepreloader.js",
	"./js/webtv/deviceinfo.js",
	"./js/webtv/connectionmonitor.js",
	"./js/webtv/onlinemonitor.js",
	"./js/webtv/updater.js",
	"./js/webtv/basic.js"
];	

function startup() {
	files.reverse();
	scriptLoaded();
}

function scriptLoaded() {
	if (files.length != 0) {
		var fileName = files.pop();
		
		var head = document.getElementsByTagName("head")[0];
		script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = fileName;
		var callback = function() {
			scriptLoaded()
		};
		script.onload = callback;
		script.onerror = callback;
		head.appendChild(script);			
	} else {
		init();		
	}
}


